class SearchesController < ApplicationController
	def show
		unless params[:q].blank?
			@search_text = CGI.escapeHTML(params[:q])			
			@category = params[:category].to_i 
			
			page = params[:page]
			page ||= 1
			page = 1 if page.to_i == 0
			
			models = []
			case @category
			when 1
				models << Post
			when 2
				models << Article
			when 3
				models << Community
			else
				models << Post
				models << Article
				models << Community
			end
			
   		@entries = ActsAsFerret.find(@search_text, models, {:per_page=>20, :page=>page}, {:order=>"created_at DESC"})
		end
		@entries ||= []
	end
end
